/* ex: set tabstop=4 shiftwidth=4 expandtab: */
#ifndef _RTP_TYPES_H
#define _RTP_TYPES_H

/*\
|*|
|*| Video/Audio stream format:
|*|
|*| +-------------------------+
|*| ! rtp_channel_t           !
|*| +-------------------------+
|*| ! rtp_hdr_t               !
|*| +-------------------------+
|*| ! video(audio)_hdr_t      !
|*| +-------------------------+
|*|
\*/


typedef struct {
	unsigned int cc:4; /* contributing souce identifilers count. always 1 */
	unsigned int x:1;  /* extension */
	unsigned int p:1;  /* padding */
	unsigned int version:2;

	unsigned int pt:7; /* payload type. 97 for audio, 96 for video */
	unsigned int m:1;  /* marker */

	unsigned int seq:16; /* sequence number. start from 0 */

	unsigned int ts; /* timestamp. start from 0 */
	unsigned int ssrc; /* sync source id */
	unsigned int csrc[1]; /* contributing source identifiers. always 0 */
} rtp_hdr_t;

typedef struct {
	char tag; /* '$' */
	char channel; /* 0 for audio, 2 for video */
	unsigned short len;
} rtp_channel_t;

#define VIDEO_HDR_TAG 0xF0F0F0F0
#define AUDIO_HDR_TAG 0xE0E0E0E0


typedef struct {
	int tag; /* 0xF0F0F0F0 */
	int len; /* len of this frame. little endian */
	int frame; /* RTP timestamp div 90. little endian */
    char payload[0]; /* first 128bits SHA-1 encrypted */
                     /* key is MD5(nonce+"3B8C7905473EB41C7392BA718F084439") */
} video_hdr_t;

typedef struct {
	unsigned short index:3;
	unsigned short size:13;
} au_hdr_t;

typedef struct {
	au_hdr_t au1;
	au_hdr_t au2;
	int tag; /* 0xE0E0E0E0 */
	int len; /* len of this frame. little endian */
	int frame; /* RTP timestamp div 24. little endian */
    char payload[0]; /* first 128bits SHA-1 encrypted. same key as video */
} audio_hdr_t;

#endif
